package cn.slipi.common.configuration;

import cn.slipi.common.handler.BizExceptionHandler;
import cn.slipi.common.handler.DefaultExceptionHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.List;

@Configuration
public class ExceptionConfiguration extends WebMvcConfigurationSupport {

    @Autowired
    private BizExceptionHandler bizExceptionHandler;

    @Autowired
    private DefaultExceptionHandler defaultExceptionHandler;


    @Override
    protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
        exceptionResolvers.add(bizExceptionHandler);
        exceptionResolvers.add(defaultExceptionHandler);
    }
}
